<template>
	<!-- height:calc(100vh - 60px); -->
	<view class="aside-index">
		<view v-if="aiList[0]" ref="uv-back-top" style="px;transition: width 2s;border-right:1px solid #E9ECEF">
			<uv-form labelPosition="left" :model="imagine" :rules="rules" ref="form">
				<uv-form-item labelWidth="80" label="模型版本" prop="imagine.name" borderBottom>
					<uni-data-select @change="changeV" :clear="false" v-model="sas_v"
						:localdata="models"></uni-data-select>
				</uv-form-item>
				<!-- <uv-form-item v-if="false" labelWidth="80" label="模型" prop="imagine.name" borderBottom>
					<view class="imagine_content"
						style="width:100% ; display: flex;justify-content: flex-start;align-items: center;flex-wrap: wrap;">
						<view style="margin-right: 20px;" v-for="(item, index) in modes" :key="index">
							<uv-tags v-if="item.tag.includes('imagine')" :text="`${item.name}`" :plain="item.value != imagine['model']"
								type="warning" :name="index" @click="clicklist(item)">
							</uv-tags>
						</view>
					</view>
				</uv-form-item> -->
				<uv-form-item labelWidth="80" label="生成速度" prop="imagine.name" borderBottom>
					<uni-data-select :clear="false" v-model="imagine.mode" :localdata="modes"></uni-data-select>
				</uv-form-item>

				<view style="font-size: 14px;display: block;">图片比例</view>
				<uv-form-item labelWidth="80" label="" prop="imagine.size" borderBottom>
					<view class="imgrate">
						<view v-for="(item,index) in ratioSize" :key="item.text"
							:class="sas_ar == item.value?'item_ss cursor-pointer item_ss_acting':'item_ss cursor-pointer'"
							@click="sas_ar = item.value;">
							<view style="height: 70%;display: flex;justify-content: center;align-items: center;">
								<!-- {{clacRate(item)}} -->
								<view class="item_xx" :style="[{
									width: $uv.addUnit(clacRate(item)[0]),
										height: $uv.addUnit(clacRate(item)[1])
									}]">
								</view>
							</view>
							<view class="item_text">{{item.text}}</view>
						</view>
					</view>
				</uv-form-item>

				<uv-form-item labelWidth="90" label="画质(q)" prop="imagine.quality" borderBottom>
					<uni-data-select v-model="sas_q" :localdata="qualitys"></uni-data-select>
				</uv-form-item>
				<uv-form-item labelWidth="120" label="艺术程度(s)" prop="imagine.name">
					<view class="uv_unm">
						<uv-number-box inputWidth="100" :min="0" :max="1000" integer :step="10" v-model="s"
							@change="e=>handnum(e,'s')">
							<!-- button-size="36" color="#2979ff" bgColor="#EEEEEE"
							iconStyle="color: #323233" -->
							<template v-slot:minus>
								<view class="minus" v-if="s>0">
									<uv-icon name="minus" color="#FFFFFF" size="12">
									</uv-icon>
								</view>
							</template>
							<template v-slot:plus>
								<view class="plus" v-if="s<1000">
									<uv-icon name="plus" color="#FFFFFF" size="12"></uv-icon>
								</view>
							</template>
						</uv-number-box>
					</view>
				</uv-form-item>
				<uv-form-item labelWidth="120" label="多样性(chaos)" prop="imagine.name">
					<view class="uv_unm">
						<uv-number-box inputWidth="100" :min="0" :max="100" integer :step="5" v-model="chaos"
							@change="e=>handnum(e,'chaos')">
							<!-- button-size="36" color="#2979ff" bgColor="#EEEEEE"
							iconStyle="color: #323233" -->
							<template v-slot:minus>
								<view class="minus" v-if="chaos>0">
									<uv-icon name="minus" color="#FFFFFF" size="12">
									</uv-icon>
								</view>
							</template>
							<template v-slot:plus>
								<view class="plus" v-if="chaos<1000">
									<uv-icon name="plus" color="#FFFFFF" size="12"></uv-icon>
								</view>
							</template>
						</uv-number-box>
					</view>
				</uv-form-item>
				<uv-form-item v-if="filterString(sas_v)>=7" labelWidth="120" label="更艺术化(exp)" prop="imagine.name">
					<view class="uv_unm">
						<uv-number-box inputWidth="100" :min="0" :max="100" integer :step="5" v-model="exp"
							@change="e=>handnum(e,'exp')">
							<!-- button-size="36" color="#2979ff" bgColor="#EEEEEE"
							iconStyle="color: #323233" -->
							<template v-slot:minus>
								<view class="minus" v-if="exp>0">
									<uv-icon name="minus" color="#FFFFFF" size="12">
									</uv-icon>
								</view>
							</template>
							<template v-slot:plus>
								<view class="plus" v-if="exp<1000">
									<uv-icon name="plus" color="#FFFFFF" size="12"></uv-icon>
								</view>
							</template>
						</uv-number-box>
					</view>
				</uv-form-item>
				<view style="background-color: #fff;border-radius: 5px;padding: 0px">
					<view @click="uploadShow = !uploadShow" style="display: flex;justify-content: space-between;">
						<view style="font-weight: bolder;padding: 8px 0px 8px 5px;">
							图生图/风格一致性/角色一致性
						</view>
						<view class="cdd" style="margin: 3px;padding: 5px;border-radius: 5px;">
							<uv-icon style="cursor: pointer;" :name="uploadShow?'arrow-down':'arrow-left'"
								size="20"></uv-icon>
						</view>
					</view>
					<view v-if="uploadShow" style="padding: 10px 5px;">
						<view v-if="filterString(sas_v)>=6"
							style="margin-left: 5px;padding-bottom: 6px;border-bottom: 1px solid #2979ff;">
							<view
								style="display: flex;justify-content: flex-start;align-items: center; width: 100%;margin-bottom: 10px;">
								<view style="font-weight: bold;font-size: 14px;">
									图生图
								</view>
								<view style="margin-left: 10px;font-size: 12px;">
									请选择垫图的图片
								</view>
							</view>
							<view
								style="display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: center;width: 100%;height: auto;margin-bottom: 5px;">
								<view v-for="(itm,idx) in urliw" :key="idx"
									style="position: relative;margin-right: 10px;margin-bottom: 5px;">
									<view class="item_dsh" @click="urliw.splice(idx, 1)">
										<uv-icon color="#FFF" bold name="close"></uv-icon>
									</view>
									<uv-image @click="preview(itm.url)" mode="fill" :src="itm.url" width="60px"
										height="60px" radius="6px"></uv-image>
								</view>
								<view v-if="urliw.length<10" class="cursor-pointer" @click="prefixclick(1)">
									<view
										style="background-color: #F4F5F7;border-radius: 4px;border: 1px solid #FFAAFF;padding: 15px;">
										<uv-icon style="opacity: 0.4;" name="camera-fill" size="28"></uv-icon>
									</view>
								</view>
								<document maxCount="10" accept="image" uploadText="可以多图,最多6张" ref="document1"
									v-model="urliw">
								</document>
							</view>
							<view
								style="border-radius: 5px;border: 1px solid #ccc;display: flex;justify-content: space-between;align-items: center;">
								<view style="width: 40%;padding-left:10px;font-size: 15px;">
									--iw 权重一致性强度<el-tooltip style="margin-left: 10px;" effect="dark"
										content="--iw 值越高，上传的图像对最终效果的影响就越大" placement="top">
										<i style="margin-right: 3px;" class="el-icon-info"></i>
									</el-tooltip>
								</view>
								<view class="iwStyle" style="width: 59%;padding-right: 5px;">
									<uv-form-item labelWidth="80" prop="imagine.name">
										<uni-data-select :disabled="!urliw[0]" v-model="sas_iw"
											:localdata="iws"></uni-data-select>
									</uv-form-item>
								</view>
							</view>
						</view>
						<view v-else>
							{{this.reiw()}}
						</view>
						<view v-if="filterString(sas_v)>=6"
							style="margin-left: 5px;padding-bottom: 5px;border-bottom: 1px solid #2979ff;">
							<view
								style="display: flex;justify-content: flex-start;align-items: center; width: 100%;margin-bottom: 10px;">
								<view style="font-weight: bold;font-size: 14px;">
									风格一致性(--sref)
								</view>
								<view style="margin-left: 10px;font-size: 12px;">
									请选择风格相似的图片
								</view>
							</view>
							<view
								style="display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: center;width: 100%;height: auto;margin-bottom: 5px;">
								<view v-for="(itm,idx) in urlsref" :key="idx"
									style="position: relative;margin-right: 10px;margin-bottom: 5px;">
									<view class="item_dsh" @click="urlsref.splice(idx, 1)">
										<uv-icon color="#FFF" bold name="close"></uv-icon>
									</view>
									<uv-image @click="preview(itm.url)" mode="fill" :src="itm.url" width="60px"
										height="60px" radius="6px"></uv-image>
								</view>
								<view v-if="urlsref.length<6" class="cursor-pointer" @click="prefixclick(2)">
									<view
										style="background-color: #F4F5F7;border-radius: 4px;border: 1px solid #FFAAFF;padding: 15px;">
										<uv-icon style="opacity: 0.4;" name="camera-fill" size="28"></uv-icon>
									</view>
								</view>
								<document maxCount="6" accept="image" uploadText="可以多图,最多6张" ref="document2"
									v-model="urlsref">
								</document>
							</view>
							<view
								style="border-radius: 5px;border: 1px solid #ccc;display: flex;justify-content: space-between;align-items: center;">
								<view style="width: 40%;padding-left:10px;font-size: 15px;">
									--sw 风格一致性强度<el-tooltip style="margin-left: 10px;" effect="dark"
										content="这个值越低生成的四张图风格越相似，反之差异越大" placement="top">
										<i style="margin-right: 3px;" class="el-icon-info"></i>
									</el-tooltip>
								</view>
								<view style="width: 59%;">
									<uv-slider :disabled="!urlsref[0]" v-model="sw" :show-value="true"
										@change="e=>handparam(e,'sw')"></uv-slider>
								</view>
							</view>
						</view>
						<view v-else>
							{{this.resref()}}
						</view>
						<view v-if="filterString(sas_v)<7" style="margin-left: 5px;">
							<view
								style="display: flex;justify-content: flex-start;align-items: center; width: 100%;margin-bottom: 10px;">
								<view style="font-weight: bold;font-size: 14px;">
									角色一致性(--cref)
								</view>
								<view style="margin-left: 10px;font-size: 12px;">
									请选择包含人脸的图片
								</view>
							</view>
							<view class=""
								style="display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: center;width: 100%;height: auto;margin-bottom: 5px;">
								<view v-for="(itm,idx) in urlcref" :key="idx"
									style="position: relative;margin-right: 10px;margin-bottom: 5px;">
									<view class="item_dsh" @click="urlcref.splice(idx, 1)">
										<uv-icon color="#FFF" bold name="close"></uv-icon>
									</view>
									<uv-image @click="preview(itm.url)" mode="fill" :src="itm.url" width="60px"
										height="60px" radius="6px"></uv-image>
								</view>
								<view v-if="urlcref.length<1" class="cursor-pointer" @click="prefixclick(3)">
									<view
										style="background-color: #F4F5F7;border-radius: 4px;border: 1px solid #FFAAFF;padding: 15px;">
										<uv-icon style="opacity: 0.4;" name="camera-fill" size="28"></uv-icon>
									</view>
								</view>
								<document maxCount="1" accept="image" uploadText="可以多图,最多6张" ref="document3"
									v-model="urlcref">
								</document>
							</view>
							<view
								style="border-radius: 5px;border: 1px solid #ccc;display: flex;justify-content: space-between;align-items: center;">
								<view style="width: 40%;padding-left:10px;font-size: 15px;">
									--cw 角色一致性强度<el-tooltip style="margin-left: 10px;" effect="dark"
										content="强度为0时会专注面部一致，强度为 100 时会同时参考面部、头发和衣服。" placement="top">
										<i style="margin-right: 3px;" class="el-icon-info"></i>
									</el-tooltip>
								</view>
								<view style="width: 59%;">
									<uv-slider :disabled="!urlcref[0]" v-model="cw" :show-value="true"
										@change="e=>handparam(e,'cw')"></uv-slider>
								</view>
							</view>
						</view>
						<view v-else>
							{{this.recref()}}
						</view>
						<view v-if="filterString(sas_v)==7" style="margin-left: 5px;">
							<view
								style="display: flex;justify-content: flex-start;align-items: center; width: 100%;margin-bottom: 10px;">
								<view style="font-weight: bold;font-size: 14px;">
									图片一致性(--oref)
								</view>
								<view style="margin-left: 10px;font-size: 12px;">
									从该图中提取角色、物体、生物等视觉特征
								</view>
							</view>
							<view
								style="display: flex; justify-content: flex-start; flex-wrap: wrap; align-items: center;width: 100%;height: auto;margin-bottom: 5px;">
								<view v-for="(itm,idx) in urloref" :key="idx"
									style="position: relative;margin-right: 10px;margin-bottom: 5px;">
									<view class="item_dsh" @click="urloref.splice(idx, 1)">
										<uv-icon color="#FFF" bold name="close"></uv-icon>
									</view>
									<uv-image @click="preview(itm.url)" :src="itm.url" width="60px" height="60px"
										radius="6px"></uv-image>
								</view>
								<view v-if="urloref.length<1" class="cursor-pointer" @click="prefixclick(4)">
									<view
										style="background-color: #F4F5F7;border-radius: 4px;border: 1px solid #FFAAFF;padding: 15px;">
										<uv-icon style="opacity: 0.4;" name="camera-fill" size="28"></uv-icon>
									</view>
								</view>
								<document maxCount="1" accept="image" uploadText="可以多图,最多6张" ref="document4"
									v-model="urloref">
								</document>
							</view>
							<view
								style="border-radius: 5px;border: 1px solid #ccc;display: flex;justify-content: space-between;align-items: center;">
								<view style="width: 40%;padding-left:10px;font-size: 15px;">
									--ow 图片一致性强度<el-tooltip style="margin-left: 10px;" effect="dark"
										content="控制参考图对生成结果的影响强度，取值范围 1-1000，默认 100，建议 400 以下以保证稳定性" placement="top">
										<i style="margin-right: 3px;" class="el-icon-info"></i>
									</el-tooltip>
								</view>
								<view style="width: 50%;padding: 5px">
									<uv-number-box inputWidth="100" :min="1" :max="1000" integer :step="5" v-model="ow"
										@change="e=>handnum(e,'ow')"></uv-number-box>
								</view>
							</view>
						</view>
						<view v-else>
							{{this.reoref()}}
						</view>
					</view>
				</view>
				<div class="demo-input-suffix" style="margin-top: 10px;">
					<target ref="target" title="创意描述词" v-model="msg" :disabled.sync="disabled"></target>
					<el-input @focus="$emit('focus')" style="margin-top: 3px;" type="textarea" :autosize="{ minRows: 3}"
						placeholder="描写图片详情,如:谁,长什么样,什么时候,在哪里,做什么,画面细节什么样" v-model="msg">
					</el-input>
				</div>
				<view v-if="false" style="margin-top: 5px;background-color: #fff;border-radius: 5px;padding: 10px 5px;">
					<view @click="imageShow = !imageShow" style="display: flex;justify-content: space-between;">
						<view style="font-weight: bolder;">
							图片转mjy
						</view>
						<!-- color="#2979ff" -->
						<view class="">
							<uv-icon :name="imageShow?'arrow-down':'arrow-left'" size="20"></uv-icon>
						</view>
					</view>
					<view v-if="imageShow" style="margin-top: 10px;">
						<view v-if="filterString(sas_v)>=6" style="margin-left: 5px;">
							<view
								style="display: flex;justify-content: flex-start;align-items: center; width: 100%;margin-bottom: 10px;">
								<view style="font-weight: bold;font-size: 14px;">
									图转mjy提示词
								</view>
								<view style="margin-left: 10px;font-size: 12px;">
									请选择要转换的图片
								</view>
							</view>
							<view class="" style="width: 100px;height: auto;margin-bottom: 5px;">
								<uploads style="width: 100px;height: auto;" :name="3" :fileList="urliw">
								</uploads>
							</view>
							<view
								style="border-radius: 5px;border: 1px solid #ccc;display: flex;justify-content: space-between;align-items: center;">
								<view style="width: 40%;padding-left:10px;font-size: 15px;">
									--iw 风格一致性强度<el-tooltip style="margin-left: 10px;" effect="dark"
										content="--iw 值越高，上传的图像对最终效果的影响就越大" placement="top">
										<i style="margin-right: 3px;" class="el-icon-info"></i>
									</el-tooltip>
								</view>
								<view style="width: 59%;">
									<uv-form-item labelWidth="80" label="" prop="imagine.name" borderBottom>
										<uni-data-select :disabled="!urliw[0]" v-model="sas_iw"
											:localdata="iws"></uni-data-select>
									</uv-form-item>
								</view>
							</view>
						</view>
					</view>
				</view>
				<div class="demo-input-suffix" style="margin-top: 10px;">
					<target ref="target" title="不想出现的词" v-model="no" :disabled.sync="disabled"></target>
					<el-input style="margin-top: 3px;" type="textarea" :autosize="{ minRows: 2}"
						placeholder="输入不想出现在画面中的关键词（例如：树木、建筑等）" v-model="no" @change="e=>handparam(e,'no')">
					</el-input>
				</div>
				<view style="margin-top: 10px;font-size: 14px;">提示词工作台</view>
				<!-- <view style="display: flex;justify-content: flex-start;flex-wrap: wrap;">
					<view v-for="(item,index) in ss" :key="index" style="margin-right: 5px;margin-bottom: 5px;">
						<uv-tags v-if="item.includes('--')&&!item.includes('--no')" :text="item+' '+ss[index+1]"></uv-tags>
					</view>
				</view> -->
				<el-input style="margin-top: 5px;" disabled type="textarea" :autosize="{ minRows: 2, maxRows: 4}"
					placeholder="提示词工作台" v-model="parms">
				</el-input>
				<el-link style="font-size: 12px;opacity: 0;height: 0px !important;" type="primary">{{fill}}</el-link>
				<view style="display: flex;justify-content: space-between;">
					<uv-button :disabled="disabled" style="width: 49%;" type="primary" text="提 交"
						@click="submit"></uv-button>
					<uv-button style="width: 49%;" type="error" text="清 空" @click="reset"></uv-button>
				</view>
			</uv-form>
		</view>
		<uv-toast ref="toast"></uv-toast>
	</view>
</template>

<script>
	// 引入
	import tabbars from '@/components/tabbar/tabbar';
	import {
		task,
		index,
		taskId,
		getScroll,
		scroll,
		apiId,
		api,
	} from '@/common/api.js';
	import document from '@/components/document/document.vue';
	import config from '@/common/config';
	import target from '@/components/target/target.vue';
	export default {
		components: {
			// 注册组件
			document,
			target
		},
		props: {
			minWidth: {
				type: [Number, String],
				default: 1
			},
			aside: {
				type: Boolean,
				default: false
			},
			deepColor: {
				type: String,
				default: '#4D4D4D'
			},
			shallowColor: {
				type: String,
				default: '#808080'
			},
			lightColor: {
				type: String,
				default: '#ccc'
			},
			aicurrent: {
				type: Number,
				default: 0
			},
			type: {
				type: String,
				default: 'imagine'
			},
			mjyInfo: Object,
		},
		data() {
			return {
				fill: config.fill,
				tabbarsValue: 'imagine',
				scrollTop: 0,
				isFirstLoad: true, // 标志变量，用于判断是否首次加载
				id: '',
				data: [],

				disabled: false,
				disabledNum: 0,
				uploadShow: false,
				imageShow: false,
				ai: "painting",

				modes: [{
					value: 'relax',
					text: "一般"
				}, {
					value: 'fast',
					text: "快速"
				}, {
					value: 'turbo',
					text: "最快"
				}],
				qualitys: [{
					value: ' --q 0.25',
					text: "一般"
				}, {
					value: ' --q 0.5',
					text: "清晰"
				}, {
					value: ' --q 1',
					text: "高清"
				}, {
					value: ' --q 2',
					text: "超高清"
				}],
				iws: [{
					value: ' --iw 0.25',
					text: "相似度25%"
				}, {
					value: ' --iw 0.3',
					text: "相似度30%"
				}, {
					value: ' --iw 0.5',
					text: "相似度40%"
				}, {
					value: ' --iw 1',
					text: "相似度50%"
				}, {
					value: ' --iw 1.25',
					text: "相似度60%"
				}, {
					value: ' --iw 1.5',
					text: "相似度70%"
				}, {
					value: ' --iw 1.75',
					text: "相似度80%"
				}, {
					value: ' --iw 2',
					text: "相似度90%"
				}],
				models: [{
						value: ' --v 7.0',
						text: "MJ V7.0"
					}, {
						value: ' --v 6.1',
						text: "MJ V6.1"
					}, {
						value: ' --v 6.0',
						text: "MJ V6"
					}, {
						value: ' --v 5.2',
						text: "MJ V5.2"
					}, {
						value: ' --v 5.1',
						text: "MJ V5.1"
					}, {
						value: ' --niji 6',
						text: "Niji V6"
					}, {
						value: ' --niji 5',
						text: "Niji V5"
					}, {
						value: ' --niji 4',
						text: "Niji V4"
					}
					// , {
					// 	value: ' Niji Journey',
					// 	text: "Niji Journey"
					// },
				],
				urliw: [],
				urlsref: [],
				urlcref: [],
				urloref: [],
				sref: "",
				cref: "",
				oref: "",
				sw: 0,
				cw: 0,
				ow: 0,
				chaos: 0,
				exp: 0,
				s: 100,
				sas_cw: "",
				sas_sw: "",
				sas_no: "",
				sas_ow: "",
				sas_iw: "",
				sas_ar: " --ar 1:1",
				sas_q: " --q 1",
				sas_s: " --s 100",
				sas_v: " --v 7.0",
				sas_chaos: "",
				sas_exp: "",
				msg: "",
				no: "",
				imagine: {
					prompt: "",
					getUImages: true,
					mode: "turbo",
					translation: true,
				},

				value: 1,
				range: [{
						value: 0,
						text: "赛博朋克"
					},
					{
						value: 1,
						text: "星际"
					},
					{
						value: 2,
						text: "动漫"
					}, {
						value: 2,
						text: "日本漫画"
					}, {
						value: 2,
						text: "水墨画风格"
					}, {
						value: 2,
						text: "原创"
					}, {
						value: 2,
						text: "风景画"
					},
				],
				dataLoaded: false,
				ratioSize: [{
						text: '16:9',
						value: ' --ar 16:9',
					},
					{
						text: '5:4',
						value: ' --ar 5:4',
					},
					{
						text: '4:3',
						value: ' --ar 4:3',
					},
					{
						text: '3:2',
						value: ' --ar 3:2',
					},
					{
						text: '1:1',
						value: ' --ar 1:1',
					},
					{
						text: '3:4',
						value: ' --ar 3:4',
					},

					{
						text: '9:16',
						value: ' --ar 9:16',
					}
				],
				rules: {
					'userInfo.name': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
					'userInfo.sex': {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
				},
			}
		},
		watch: {
			disabled(newVal, oldVal) {
				console.log(newVal)
			},
			// 监听data数据的变化
			imagine: {
				handler: function(newVal, oldVal) {
					this['config_' + this.tabbarsValue][this.type] = newVal
					this.$uv.vuex('config_' + this.tabbarsValue, this['config_' + this.tabbarsValue]);
				},
				deep: true
			},
			aicurrent: {
				handler: function(newVal, oldVal) {
					this.imagine['ai'] = this.aiList[newVal].value;
				},
				deep: true
			},
			urlsref(newVal, oldVal) {
				this.sref = newVal[0]?.url ? ' --sref ' + newVal[0]?.url : '';
				this.handparam(this.sw, 'sw', !this.sref)
			},
			urlcref(newVal, oldVal) {
				this.cref = newVal[0]?.url ? ' --cref ' + newVal[0]?.url : '';
				this.handparam(this.cw, 'cw', !this.cref)
			},
			urloref(newVal, oldVal) {
				this.oref = newVal[0]?.url ? ' --oref ' + newVal[0]?.url : '';
				this.handparam(this.ow, 'ow', !this.oref)
			},
			mjyInfo: {
				handler(newVal) {
					this.reset();
					this.imagine = newVal;
					if (JSON.stringify(newVal) != "{}") {
						this.analysis();
					}
				},
				immediate: true
			}

		},
		mounted() {
			this.tabbarsValue = this.pages();
			this.reset();
			if (JSON.stringify(this.mjyInfo) != "{}") {
				this.imagine = this.mjyInfo;
				this.analysis();
			}
		},
		computed: {
			parms() {
				if (this.msg.includes('--') || this.msg.includes(' -') || this.msg.includes('- ') || this.no.includes(
						' -') || this.no.includes('- ') || this.no.includes('--')) {
					this.disabled = true;
					if (this.disabledNum == 0) {
						uni.showToast({
							title: "输入提示词错误！",
							icon: 'none', // 图标类型，可选值：success, none
							duration: 2000 // 显示时间，单位毫秒
						});
					}
					this.disabledNum = this.disabledNum + 1;
				} else {
					this.disabledNum = 0;
					this.disabled = false;
				}
				var iw = (this.sas_iw && this.urliw[0]) ? this.urliw[0].url + ' ' : '';
				return this.sas_ar + (iw ? this.sas_iw : '') + this.sas_v + this.sas_s + this.sas_q + this.oref +
					this.sas_ow + this.sas_chaos + this.sas_exp + this.sref + this.sas_sw + this.cref + this.sas_cw + this
					.sas_no;
			},
		},
		methods: {
			preview(e) { // 预览图片
				uni.previewImage({
					// current: i,
					urls: [e]
				});
			},
			prefixclick(i) {
				this.$nextTick(() => {
					this.$refs['document' + i].visible();
				});
			},
			filterString(str) {
				return str.replace(/[^0-9.]/g, ''); // 移除所有非数字和非小数点的字符
			},
			changeV(e) {
				if (e == ' --v 7.0') {
					for (var i = 0; i < this.modes.length; i++) {
						if (this.modes[i].value == 'fast') {
							this.modes[i]['disable'] = true;
							console.log(this.imagine.mode == 'fast', this.imagine.mode);
							this.imagine.mode = (this.imagine.mode == 'fast' ? 'turbo' : this.imagine.mode);
						}
					}

				} else {
					for (var i = 0; i < this.modes.length; i++) {
						if (this.modes[i].value == 'fast') {
							this.modes[i]['disable'] = false;
						}
					}
				}
			},
			clacRate(e) {
				let w = e.text.split(':')[0];
				let h = e.text.split(':')[1];
				if (w * 11 < 20 || h * 11 < 20) {
					w = w * 25;
					h = h * 25;
				} else if (w * 6 < 20 || h * 6 < 20) {
					w = w * 8;
					h = h * 8;
				} else if (w * 4 < 20 || h * 4 < 20) {
					w = w * 7;
					h = h * 7;
				} else if (w * 1.5 < 20 || w * 1.5 < 20) {
					w = w * 2.5;
					h = h * 2.5;
				} else {
					w = w * 2;
					h = h * 2;
				}
				return [w, h];
			},
			analysis() {
				if (!this.imagine.prompt) return;
				const msgs = this.imagine.prompt.split(' --');
				if (msgs[0].includes('http')) {
					var arr = msgs[0].split(' ');
					this.urliw = [{
						url: arr[0]
					}];
					this.msg = msgs[0].replace(arr[0] + ' ', '');
				} else {
					this.msg = msgs[0];
				}

				var str = ['--ar','--chaos', '--exp', '--v', '--q', '--stylize', '--s', '--sw', '--no', '--cw', '--ow', '--iw'];
				var str2 = ['--cref', '--sref', '--oref'];
				var str3 = ['--cref', '--sref', '--oref'];
				var str4 = ['--niji'];

				const array = this.imagine.prompt.split(' ');
				for (var i = 0; i < array.length; i++) {
					if (str.includes(array[i])) {
						this[array[i].replace('--', 'sas_')] = ' ' + array[i] + ' ' + array[i + 1];
						this[array[i].replace('--', '')] = array[i + 1];
					}
					if (str2.includes(array[i])) {
						this[array[i].replace('--', '')] = array[i + 1];
					}
					if (str3.includes(array[i])) {
						this[array[i].replace('--', 'url')] = [{
							url: array[i + 1]
						}];
					}
					if (str4.includes(array[i])) {
						this['sas_v'] = ' ' + array[i] + ' ' + array[i + 1];
					}
				}
			},
			reset() {
				if (this.$refs.target) this.$refs.target.clear();
				this.resref();
				this.recref();
				this.reoref();
				this.reiw();
				this.chaos = 0;
				this.exp = 0;
				this.sas_s = " --s 100";
				this.sas_ar = " --ar 1:1";
				this.sas_q = " --q 1";
				this.sas_no = "";
				this.sas_v = " --v 7.0";
				this.sas_chaos = "";
				this.sas_exp = "";
				this.msg = "";
				this.no = "";
				this.imagine = {
					prompt: "",
					getUImages: true,
					mode: "fast",
				};
			},
			reiw() {
				this.urliw = [];
				this.sas_iw = "";
			},
			resref() {
				this.urlsref = [];
				this.sw = 10;
				this.sas_sw = "";
				this.sref = "";
			},
			recref() {
				this.urlcref = [];
				this.cref = "";
				this.cw = 10;
				this.sas_cw = "";
			},
			reoref() {
				this.urloref = [];
				this.ow = 100;
				this.sas_ow = "";
				this.oref = "";
			},
			handnum(e, n) {
				console.log(e);
				if (e.value == 0) {
					this['sas_' + n] = "";
				} else {
					this['sas_' + n] = " --" + n + " " + e.value;
				}
			},
			handparam(e, n, url = '') {
				this['sas_' + n] = url ? '' : (" --" + n + " " + e);
			},
			submit() {
				var that = this;
				if (this.msg && this.parms) {
					this.disabled = true;
					var iw = (this.sas_iw && this.urliw[0]) ? this.urliw[0].url + ' ' : '';
					this.imagine.prompt = iw + this.msg +
						this.parms;
					this.$emit('focus');
					this.$emit('imagine', this.imagine);
					setTimeout(function() {
						that.disabled = false;
					}, 3000)
				} else {
					this.$refs.toast.show({
						type: 'error',
						message: "创意描述为空！"
					})
				}
			},
			clicklist(ite) {
				this.sas_v = ite.value;
				this.$uv.vuex('config_' + this.tabbarsValue, this.imagine);
			},
			formatValue(val, name) {
				this.imagine[name] = val / 100;
				return val / 100;
			},
			pages() {
				var pages = getCurrentPages() // 获取栈实例
				let currentRoute = pages[pages.length - 1].route; // 获取当前页面路由
				let currentPage = pages[pages.length - 1]['$page']['fullPath'] //当前页面路径(带参数)
				return currentPage.split('/')[2];
			},
			times(time) {
				return " -- " + uni.$uv.timeFrom(new Date(time).getTime()) + " -- ";
			},
			routes(url) {
				this.routed('/pages' + url);
			},
			routed(url) {
				console.log('routed', url)
				uni.$uv.route({
					url: url,
					intercept(params, next) {
						console.log(params, next)
						uni.showLoading({
							title: '等待中...'
						})
						// 模拟处理等待
						setTimeout(() => {
							uni.hideLoading();
							next(true);
						}, 1000)
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "@/uni_modules/uv-ui-tools/index.scss";

	.aside-index {
		height: 100%;
		width: 100%;

		.cdd:hover {
			background-color: #eee;
		}

		.imgrate {
			display: flex;
			justify-content: space-between;
			align-items: center;
			flex-wrap: wrap;
			width: 100%;

			.item_ss {
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: center;
				border: 1px solid #cccccc;
				border-radius: 5px;
				width: 60px;
				height: 70px;
				color: #666666;
				margin-bottom: 10px;

				.item_xx {
					background: linear-gradient(to left, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) left top no-repeat,
						linear-gradient(to bottom, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) left top no-repeat,
						linear-gradient(to left, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) right top no-repeat,
						linear-gradient(to bottom, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) right top no-repeat,
						linear-gradient(to left, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) left bottom no-repeat,
						linear-gradient(to bottom, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) left bottom no-repeat,
						linear-gradient(to left, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) right bottom no-repeat,
						linear-gradient(to left, rgba(120, 109, 245, .5), rgba(120, 109, 245, 0.5)) right bottom no-repeat;
					background-size: 2px 6px, 6px 2px, 2px 6px, 6px 2px;
					// background-color: #d0e2f5;
					margin-top: 0px;
					background-color: #cccccc;
					border: 1px solid #fff;
				}

				.item_text {
					height: 30%;
					padding: 2px 5px;
					bottom: 0px;
				}
			}

			.item_ss_acting {
				border: 1px solid #C6000B;

				.item_xx {
					// background: linear-gradient(to left, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) left top no-repeat,
					// 	linear-gradient(to bottom, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) left top no-repeat,
					// 	linear-gradient(to left, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) right top no-repeat,
					// 	linear-gradient(to bottom, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) right top no-repeat,
					// 	linear-gradient(to left, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) left bottom no-repeat,
					// 	linear-gradient(to bottom, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) left bottom no-repeat,
					// 	linear-gradient(to left, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) right bottom no-repeat,
					// 	linear-gradient(to left, rgba(170, 0, 0, 0.5), rgba(255, 85, 0, 0.5)) right bottom no-repeat;
					// background-size: 2px 6px, 6px 2px, 2px 6px, 6px 2px;
					// background-color: #ff85f7;
					background-color: #C6000B;
					border: 1px solid #fdff7b;
				}

				.item_text {
					color: #C6000B;
				}
			}
		}

		.iwStyle {
			::v-deep .uv-form-item__body {
				padding: 5px 0px;
			}
		}

		.uv_unm {
			.minus {
				width: 35px;
				height: 30px;
				background-color: #FF0000;
				/* #ifndef APP-NVUE */
				display: flex;
				/* #endif */
				justify-content: center;
				align-items: center;
			}

			.plus {
				width: 35px;
				height: 30px;
				background-color: #FF0000;
				/* #ifndef APP-NVUE */
				display: flex;
				/* #endif */
				justify-content: center;
				align-items: center;
			}
		}

		.item_dsh {
			position: absolute;
			z-index: 10;
			top: 0px;
			right: 0px;
			background-color: #000;
			padding: 5px 6px;
			color: #fff;
			border-top-right-radius: 10px;
			border-bottom-left-radius: 10px;
			cursor: pointer;
		}
	}

	/* 测试 */
	.view_circle0 {
		display: flex;
		justify-content: space-between;

		margin: 50upx;
		width: 200upx;
		height: 200upx;
		border-radius: 50%;
		/* inset 表示内阴影 */
		/* box-shadow: 0 3px 150upx #62d0d6 inset; */
		box-shadow: -10px 0px 50upx #7ce2c0,
			/*左边阴影*/
			0px -10px 50upx #65dee2,
			/*上边阴影*/
			10px 0px 50upx #f7dc77,
			/*右边阴影*/
			0px 10px 50upx #c84848;
		animation: turn 1s linear infinite;
	}

	/* 
		      turn : 定义的动画名称
		      1s : 动画时间
		      linear : 动画以何种运行轨迹完成一个周期
		      infinite :规定动画应该无限次播放
		     */
	@keyframes turn {
		0% {
			-webkit-transform: rotate(0deg);
		}

		25% {
			-webkit-transform: rotate(90deg);
		}

		50% {
			-webkit-transform: rotate(180deg);
		}

		75% {
			-webkit-transform: rotate(270deg);
		}

		100% {
			-webkit-transform: rotate(360deg);
		}
	}

	.uv-form {
		-webkit-user-select: text;
		/* Safari */
		-moz-user-select: text;
		/* Firefox */
		-ms-user-select: text;
		/* IE 10+ */
		user-select: text;
		/* Standard syntax */
	}
</style>